import req from '@/utils/req/axios'
import urls from '@/utils/constants/urls'

export const userListSelectProps = {
  multiple: true,
  filterable: true,
  remote: true,
  optionMap: { label: 'userName', value: 'id' },
  api: {
    async request(query) {
      const res = await req.post(urls.v1.system.user.list, {
        pageSize: 20,
        ...(query ? { userName: query } : {}),
      })
      return res.data
    },
    async loadByIdRequest(value) {
      const res = await req.post(urls.v1.system.user.getById, {
        id: value,
      })
      return {
        ...res.data,
        value: res.data.id,
        label: res.data.userName,
      }
    },
  },
}
